package com.crois.barrier.web.resp;

/**
 * @author Hou Ze Yu
 * @description
 * @date 2020/10/23
 */

import com.crois.barrier.common.exception.BarrierException;
import com.crois.barrier.common.exception.BarrierExceptionEnum;
import com.crois.barrier.common.response.BarrierResponse;
import com.crois.barrier.common.response.BarrierResponseEntity;
import com.crois.barrier.web.spring.SpringBeanUtils;
import lombok.Data;

import java.util.List;

/**
 * @author Hou Ze Yu
 * @description
 * @date 2020/7/8
 */
@Data
public final class BarrierResponseWrapper {

    public static BarrierResponseEntity<Void> ok(){

        BarrierResponse<BarrierResponseEntity<Void>> BarrierResponse = SpringBeanUtils.getInstance().getBean(BarrierResponse.class);

        return BarrierResponse.ok();

    }

    public static BarrierResponseEntity<?> ok(Object data){

        BarrierResponse<BarrierResponseEntity<?>> BarrierResponse = SpringBeanUtils.getInstance().getBean(BarrierResponse.class);

        return BarrierResponse.ok(data) ;
    }
    public static BarrierResponseEntity<List<?>> okList(List<?> list){
        BarrierResponse<BarrierResponseEntity<List<?>>> BarrierResponse = SpringBeanUtils.getInstance().getBean(BarrierResponse.class);
        return BarrierResponse.okList(list) ;
    }
    public static BarrierResponseEntity<Void> fail(){
        BarrierResponse<BarrierResponseEntity<Void>> BarrierResponse = SpringBeanUtils.getInstance().getBean(BarrierResponse.class);
        return BarrierResponse.fail();
    }

    public static BarrierResponseEntity<Void> fail(BarrierException barrierException){
        BarrierResponse<BarrierResponseEntity<Void>> BarrierResponse = SpringBeanUtils.getInstance().getBean(BarrierResponse.class);
        return BarrierResponse.fail(barrierException);
    }
    public static BarrierResponseEntity<Void> fail(BarrierExceptionEnum barrierExceptionEnum){
        BarrierResponse<BarrierResponseEntity<Void>> BarrierResponse = SpringBeanUtils.getInstance().getBean(BarrierResponse.class);
        return BarrierResponse.fail(barrierExceptionEnum);
    }
}
